package com.xlhj.boot.job;

import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.PersistJobDataAfterExecution;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.quartz.QuartzJobBean;

import java.time.LocalDateTime;

/**
 * @author: liucaijing
 * @description: QuartzJob
 * @date: 2021/10/27 17:03
 */
public class SimpleJob extends QuartzJobBean {

    private static final Logger logger = LoggerFactory.getLogger(SimpleJob.class);

    @Override
    protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
        logger.info("start job...当前时间为：{}", LocalDateTime.now());
        try {
            Thread.sleep(3000);
            logger.info(context.getScheduler().getSchedulerInstanceId());
            logger.info("task name is {}", context.getJobDetail().getKey().getName());
        } catch (Exception e) {
            e.printStackTrace();
        }
        logger.info("end job...当前时间为：{}", LocalDateTime.now());
    }
}
